package com.chub.study.modules.mapper;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.chub.study.modules.entity.TCity;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 行政区划表 Mapper 接口
 * </p>
 *
 * @author chub
 * @since 2021-08-26
 */
@Mapper
@Repository
public interface TCityMapper extends BaseMapper<TCity> {

    //封装成map
    @MapKey("id")
    //只能用主键
    Map<Integer, TCity> queryCityInfoAsMap(String id);

    //封装成list
    List<TCity> queryCityInfo(@Param("id") String id);

    //  这里一定要加“@Param("map") ”， 后面SQL里会用到
    List<TCity> queryCityListByMap(@Param("map") Map<String, Object> map);

    List<TCity> queryCityListByMapRespBeanList(@Param("map") Map<String, Object> map);

    //@Param("city")      对应的xml中的SQL语句中要这样用：where CITY_NAME like '%' || #{city.cityName} || '%'
    //不加 @Param("city")  对应的xml中的SQL语句中要这样用：where CITY_NAME like '%' || #{cityName} || '%'
    List<TCity> queryCityListByBean(TCity city);

    //封装成map
    @MapKey("CITY_ID")
    Map<Integer, TCity> queryCityInfoRespMap(String id);

    List<Map<String, Object>> queryCityInfoRespMap1(String id);

    List<Arrays> queryCityInfoRespArray(String id);

    List<String> queryCityInfoRespArrString(String id);

    List<TCity> queryCityInfoByList(List list);

    List<TCity> queryCityInfoByArray(String[] cityIds);

    List<TCity> queryCityInfoByMapKeyValue(@Param("map") Map<String,String>  map);
    List<TCity> queryCityInfoByMapKey(@Param("map") Map<String,String>  map);
    List<TCity> queryCityInfoByMapValue(@Param("map") Map<String,String>  map);

    List<TCity> queryCityInfoByUptTime(TCity tCity);

    @Select(
            {"<script>",
                    "SELECT * FROM t_city",
                    "WHERE 1=1",
                    "<if test=' id!=null '>",
                    "AND PARENT_ID = #{id}",
                    "</if>",
            "</script>"}
    )
    List<TCity> queryCityInfoList(String id);

    IPage<Map<String, Object>> queryByPage1(IPage<Map<String, Object>> page, Map<String, Object> forQuery);


    List<TCity> queryByParentIdReturnListBean(@RequestBody Map<String, Object> forQuery);

    List<TCity> queryByParentIdReturnListMap(@RequestBody Map<String, Object> forQuery);


    int insertAndReturnPk(@RequestBody TCity tCity);



}
